package com.yuexunit.operationman.nbsy.module.Catheter.ui;

import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.base.BaseKJActivity;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.Catheter.bean.CatheterBean;

import org.kymjs.kjframe.utils.PreferenceHelper;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2017/12/28 0028.
 */

public class Act_Catheter_Preview extends BaseKJActivity {

    @Bind(R.id.tv_patient_name)
    TextView tvPatientName;
    @Bind(R.id.tv_patient_sex)
    TextView tvPatientSex;
    @Bind(R.id.tv_patient_visitno)
    TextView tvPatientVisitno;
    @Bind(R.id.tv_patient_disease)
    TextView tvPatientDisease;
    @Bind(R.id.txt01)
    TextView txt01;
    @Bind(R.id.txt02)
    TextView txt02;
    @Bind(R.id.txt03)
    TextView txt03;
    @Bind(R.id.txt04)
    TextView txt04;
    @Bind(R.id.txt05)
    TextView txt05;
    @Bind(R.id.txt06)
    TextView txt06;
    @Bind(R.id.txt07)
    TextView txt07;
    @Bind(R.id.txt08)
    TextView txt08;
    @Bind(R.id.txt09)
    TextView txt09;
    @Bind(R.id.txt10)
    TextView txt10;
    @Bind(R.id.txt11)
    TextView txt11;
    @Bind(R.id.txt12)
    TextView txt12;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_catheter_preview);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        super.initData();
        setTitle();
        setContent();
    }

    private void setTitle() {
        tvPatientName.setText(AppConfig.CATHETERBEAN.getObject().getCatheter().getPatientName());
        if (AppConfig.CATHETERBEAN.getObject().getCatheter().getPatientSex().equals("1")) {
            tvPatientSex.setText("男");
        } else if (AppConfig.CATHETERBEAN.getObject().getCatheter().getPatientSex().equals("2")) {
            tvPatientSex.setText("女");
        } else {
            tvPatientSex.setText("不详");
        }
        tvPatientVisitno.setText("住院号" + AppConfig.CATHETERBEAN.getObject().getCatheter().getInHospitalNo());
        tvPatientDisease.setText(PreferenceHelper.readString(aty, AppConfig.PATIENT_INFO, AppConfig.PATIENT_DISEASE));
    }

    private void setContent()
    {
        for(CatheterBean.ObjectEntity.CatheterItemListEntity p : AppConfig.CATHETERBEAN.getObject().getCatheterItemList()) {
            switch (p.getItemCode()) {
                case "DGLX":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_01);
                        if(skin[0].equals("1"))
                        {
                            txt01.setText(arrays[0]);
                        }
                        if(skin[1].equals("1"))
                        {
                            txt01.setText(arrays[1]);
                        }
                        if(skin[2].equals("1"))
                        {
                            txt01.setText(arrays[2]);
                        }
                        if(skin[3].equals("1"))
                        {
                            txt01.setText(arrays[3]);
                        }
                    }
                    break;
                case "DNMD":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_02);
                        if(skin[0].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[0];
                            }
                            else {
                                content += arrays[0];
                            }
                        }
                        if(skin[1].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[1];
                            }
                            else {
                                content += arrays[1];
                            }
                        }
                        if(skin[2].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[2];
                            }
                            else {
                                content += arrays[2];
                            }
                        }
                        if(skin[3].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[3];
                            }
                            else {
                                content += arrays[3];
                            }
                        }
                        if(skin[4].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[4];
                            }
                            else {
                                content += arrays[4];
                            }
                        }
                        if(skin[5].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[5];
                            }
                            else {
                                content += arrays[5];
                            }
                        }
                        if(skin[6].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[6];
                            }
                            else {
                                content += arrays[6];
                            }
                        }
                        if(skin[7].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[7]+":"+skin[8];
                            }
                            else {
                                content += arrays[7]+":"+skin[8];
                            }
                        }

                        txt02.setText(content);
                    }
                    break;
                case "item1":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[3].equals("1"))
                        {
                            content += "口罩";
                        }
                        if(skin[4].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += ";";
                                content += "帽子";
                            }
                            else {
                                content += "帽子";
                            }
                        }
                        if(skin[0].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[0];
                            }
                            else {
                                content += arrays[0];
                            }
                        }
                        if(skin[1].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[1];
                            }
                            else {
                                content += arrays[1];
                            }
                        }
                        if(skin[2].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[2];
                            }
                            else {
                                content += arrays[2];
                            }
                        }
                        txt03.setText(content);
                    }
                    break;
                case "item2":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[0].equals("1"))
                        {
                            txt04.setText(arrays[0]);
                        }
                        if(skin[1].equals("1"))
                        {
                            txt04.setText(arrays[1]);
                        }
                        if(skin[2].equals("1"))
                        {
                            txt04.setText(arrays[2]);
                        }
                    }
                    break;
                case "item3":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[0].equals("1"))
                        {
                            txt05.setText(arrays[0]);
                        }
                        if(skin[1].equals("1"))
                        {
                            txt05.setText(arrays[1]);
                        }
                        if(skin[2].equals("1"))
                        {
                            txt05.setText(arrays[2]);
                        }
                    }
                    break;
                case "item4":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[3].equals("1"))
                        {
                            content += "女性";
                        }
                        if(skin[4].equals("1"))
                        {
                            content += "男性";
                        }
                        if(skin[0].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[0];
                            }
                            else {
                                content += arrays[0];
                            }
                        }
                        if(skin[1].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[1];
                            }
                            else {
                                content += arrays[1];
                            }
                        }
                        if(skin[2].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[2];
                            }
                            else {
                                content += arrays[2];
                            }
                        }
                        txt06.setText(content);
                    }
                    break;
                case "item5":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[0].equals("1"))
                        {
                            txt07.setText(arrays[0]);
                        }
                        if(skin[1].equals("1"))
                        {
                            txt07.setText(arrays[1]);
                        }
                        if(skin[2].equals("1"))
                        {
                            txt07.setText(arrays[2]);
                        }
                    }
                    break;
                case "item6":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[0].equals("1"))
                        {
                            txt08.setText(arrays[0]);
                        }
                        if(skin[1].equals("1"))
                        {
                            txt08.setText(arrays[1]);
                        }
                        if(skin[2].equals("1"))
                        {
                            txt08.setText(arrays[2]);
                        }
                    }
                    break;
                case "item7":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[3].equals("1"))
                        {
                            content += "女性";
                        }
                        if(skin[4].equals("1"))
                        {
                            content += "男性";
                        }
                        if(skin[0].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[0];
                            }
                            else {
                                content += arrays[0];
                            }
                        }
                        if(skin[1].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[1];
                            }
                            else {
                                content += arrays[1];
                            }
                        }
                        if(skin[2].equals("1"))
                        {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[2];
                            }
                            else {
                                content += arrays[2];
                            }
                        }
                        txt09.setText(content);
                    }
                    break;
                case "item8":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[0].equals("1"))
                        {
                            txt10.setText(arrays[0]);
                        }
                        if(skin[1].equals("1"))
                        {
                            txt10.setText(arrays[1]);
                        }
                        if(skin[2].equals("1"))
                        {
                            txt10.setText(arrays[2]);
                        }
                    }
                    break;
                case "item9":
                    if (p.getItemValue().length() > 0) {
                        String content = "";
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.catheter_03);
                        if(skin[0].equals("1"))
                        {
                            txt11.setText(arrays[0]);
                        }
                        if(skin[1].equals("1"))
                        {
                            txt11.setText(arrays[1]);
                        }
                        if(skin[2].equals("1"))
                        {
                            txt11.setText(arrays[2]);
                        }
                    }
                    break;
            }
        }
        if(AppConfig.CATHETERBEAN.getObject().getCatheter().getOperator()!=null&&AppConfig.CATHETERBEAN.getObject().getCatheter().getOperator().length()>0)
        {
            txt12.setText(AppConfig.CATHETERBEAN.getObject().getCatheter().getOperator());
        }
    }

    @OnClick(R.id.titlebar_docadvice_img_back)
    public void onClick() {
        finish();
    }
}
